<?php


class PageMakerSet extends PageMaker {


	public function SetCrudset($crudset_id){
		$this->crudset_id = $crudset_id;
	}	
	
	public function GetReplacements(){
		$ar_replace = array();
		//echo 'Project ' . $this->project_id . '  or this ' . $this->crudset_id;
		// Get project replacements
		if(empty($this->project_id) OR empty($this->crudset_id)){
			return 'Error - Project or Crudset not defined';
		}
		
		$q = Doctrine_Query::create()
		->from('Projects p')->where('project_id = ?',$this->project_id);
		$ar_projects = $q->fetchArray();
			if(is_array($ar_projects)){
			foreach($ar_projects[0] AS $project_variable=>$project_value){
				$ar_repsets = $this->GetRepsets($project_variable,$project_value);
				$ar_replace = array_merge($ar_replace,$ar_repsets);
				
			}
			}
		// pick up any extension replacements
		// function GetExtReplacements needs to return array of token=>data
		if(method_exists($this,'GetExtReplacements')){	
			$ar_ext_replacements = $this->GetExtReplacements();
			foreach($ar_ext_replacements AS $token=>$value){
				$this->ar_replacements[$token]['token'] = $token;
				$this->ar_replacements[$token]['value'] = $value;
			}
			
		}
		
		// Get crudset replacements
		$q = Doctrine_Query::create()
		->from('Crudsets c')->where('crudset_id = ?',$this->crudset_id);
		$ar_crudsets = $q->fetchArray();
			if(is_array($ar_crudsets)){		
			foreach($ar_crudsets[0] AS $crudset_variable=>$crudset_value){
				$ar_repsets = $this->GetRepsets($crudset_variable,$crudset_value);
				$ar_replace = array_merge($ar_replace,$ar_repsets);			
			}
			}
		
		
		
		$this->ar_replacements = $ar_replace;
		return $ar_replace;
	
	
	}


}


?>
